<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<jsp:include page="ajax-top.jsp" />
<div class="row" style="padding:2px">
	<div class="col-sm-12 col-md-12 col-lg-12">
		<div>
			<a href="javascript:void(0);" id="ajax_process_btn_add"  class="btn btn-default "><i class="fa fa-lg fa-plus"></i> 新建流程简要表</a>
		</div>
	</div>
</div>
<!-- rows -->
<!-- widget grid -->
<section id="widget-grid" class="">

	<!-- row -->
	<div class="row">
		<!-- NEW WIDGET START -->
		<article class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
			<!-- Widget ID (each widget will need unique ID)-->
			<div class="jarviswidget " id="wid-id-0" data-widget-editbutton="false"
				data-widget-colorbutton="false" 
				data-widget-togglebutton="false" 
				data-widget-deletebutton="false" 
				data-widget-fullscreenbutton="true" 
				data-widget-custombutton="false" 
				data-widget-sortable="false">

				<!-- widget div-->
				<div>

					<!-- widget edit box -->
					<div class="jarviswidget-editbox">
						<!-- This area used as dropdown edit box -->

					</div>
					<!-- end widget edit box -->

					<!-- widget content -->
					<div class="widget-body no-padding">
                        <div class="col-sm-12 col-md-12 col-lg-12">
                            <div class=" ">
                                <div class="row" id="ajax_process_list_row">
                                    <table id="ajax_process_table" class="table table-striped table-bordered table-hover">
                                    </table>
                                    <div id="ajax_process_list_page">
                                    </div>
                                </div>
                            </div>
                        </div>
					</div>
					<!-- end widget content -->

				</div>
				<!-- end widget div -->

			</div>
			<!-- end widget -->

		</article>
		<!-- WIDGET END -->

	</div>

	<!-- end row -->
</section>
<!-- end widget grid -->


<script type="text/javascript">


	function reload(){
		loadURL("../com/ajax!process.action",$('#content'));
	}
    $("#ajax_process_btn_add").click(function(){
		loadURL("../com/ajax-processbrief!input.action",$('div#content'));
    });


    $(function(){
            jQuery("#ajax_process_table").jqGrid({
            	url:'../com/ajax-processbrief!list.action',
        	    datatype: "json",
            	colNames:["创建日期",'流程名称',"关联的表单名称","操作","id"],
            	colModel:[
           		    {name:'createDate',index:'createDate', width:100,sortable:true,search:true,searchoptions:{sopt:['cn']}},
           		    {name:'name',index:'name', width:150,sortable:true,search:true,searchoptions:{sopt:['cn']}},
           		    {name:'tableName',index:'tableName', width:150,sortable:true,search:true,searchoptions:{sopt:['cn']}},
           		    {name:'act',index:'act', width:150,sortable:false,search:false,fixed:true},
           		    {name:'id',index:'id', width:50,key:true,hidden:true}
             	],
				loadonce: true,
                rowNum : 10,
                rowList:[10,20,30],
                pager : '#ajax_process_list_page',
                sortname : 'createDate',
                sortorder : "desc",
                gridComplete:function(){
					var ids=$("#ajax_process_table").jqGrid('getDataIDs');
					for(var i=0;i<ids.length;i++){
						var cl=ids[i];
						var rowData = $("#ajax_process_table").jqGrid("getRowData",cl);
						var de="<button class='btn btn-default' data-original-title='编辑' onclick=\"fn_process_read('"+cl+"');\"><i class='fa fa-eye'></i>编辑</button>"+" "
						var dt="<button class='btn btn-default' data-original-title='删除' onclick=\"fn_process_destroy('"+cl+"');\"><i class='fa fa-eye'></i>删除</button>"+" ";
						jQuery("#ajax_process_table").jqGrid('setRowData',ids[i],{act:de+dt});
					}
					$(".ui-jqgrid-bdiv").css("overflow-x","hidden");
					jqGridStyle();
                },
				onSelectRow: function (rowId, status, e) {
					var rowId = $("#ajax_process_table").jqGrid('getGridParam','selrow');
					var rowDatas = $("#ajax_process_table").jqGrid('getRowData', rowId);
				},
    	        jsonReader: {
    			    root: "dataRows",
    			    page: "page",
    			    total: "total",
    			    records: "records",
    			    repeatitems : false
    			},
				caption : "<i class='fa fa-arrow-circle-right'></i> 流程简要信息",
    			multiselect : false,
                rownumbers:true,
                gridview:true,
                shrinkToFit:true,
                viewrecords: true,
                autowidth: true,
                height:'auto',
                forceFit:true,
                loadComplete: function() {
                }
            });
            $(window).on('resize.jqGrid', function() {
                jQuery("#ajax_process_table").jqGrid('setGridWidth', $("#ajax_process_list_row").width());
            });
			jQuery("#ajax_process_table").jqGrid('filterToolbar',{searchOperators:false,stringResult:true});
            jQuery("#ajax_process_table").jqGrid('navGrid', "#ajax_process_list_page", {
                edit : false,
            	add : false,
            	del : false,
            	search:false
            });

    });

	function fn_process_read(id){
		loadURL("ajax-processbrief!input.action?keyId="+id, $('#content'));
	}

	function fn_process_destroy(id){
		$.tzDialog({title:"提示",content:"确认要删除吗?",callback:function(){
			var vActionUrl = "ajax-processbrief!delete.action";
			var data={keyId:id};
			ajax_action(vActionUrl,data,{},function(pdata){
				_show(pdata);
				jQuery("#ajax_process_table").jqGrid().setGridParam({datatype:'json'}).trigger("reloadGrid");
			});
		}});
	}

</script>

